<template>
  <div class="box">
    <h1>
      <i class="el-icon-folder-opened"></i>
      {{ classList[0].category.name }}
    </h1>
    <div class="cont">
      <div class="cont-item" v-for="item in classList" :key="item.id">
        <img :src="item.titleImage" alt="" />
        <h1>{{ item.title }}</h1>
        <p>{{ item.description }}</p>
        <div class="tag">
          <p v-for="item in classList.tags" :key="item.id" :v-show="item.name">
            {{ item.name }}
          </p>
        </div>
      </div>
    </div>
    <el-pagination
      @current-change="pageChange"
      :page-size="dataList.size"
      :current-page="dataList.current"
      layout="prev, pager, next"
      :total="dataList.total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { ClassAnd } from "../units/api.js";
export default {
  data() {
    return {
      dataList: {
        categoryId: "",
        current: 1,
        size: 10,
        total:1,
      },
      classList: [],
    };
  },
  created() {
    this.dataList.categoryId = this.$route.query.MyId;
    console.log(this.dataList);
    this.getList();
  },
  methods: {
    async getList() {
      let res = await ClassAnd(this.dataList);
      this.classList = res.data.data;
      console.log("这里是类型的", res);
    },
    pageChange(val) {
      // console.log(this.list.current);
      console.log(val);
      this.dataList.current = val;
      this.getList();
    },
  },
};
</script>

<style scoped>
.cont {
  display: flex;
}
.cont-item {
  margin: 1vw;
  width: 400px;
  background-color: white;
  border-radius: 8px;
}
.cont-item > img {
  width: 400px;
  height: 200px;
}
</style>